﻿using System;
using Tyshka.Subroutines.Kernel.Utility;

namespace Tyshka.Subroutines.Domain.Entities
{
    public partial class User : IEntity
    {
        public virtual Boolean IsLogged { get; set; }

        public String FullName
        {
            get
            {
                return String.Format("{0} {1}", FirstName, LastName);
            }
        }

        public virtual void SetPassword(String psw)
        {
            if (String.IsNullOrEmpty(psw)) return;

            if (psw != Password)
            {
                Salt = HashEngine.GenerateSalt();
                Password = HashEngine.GenerateHash(psw, Salt);
            }
        }
    }
}
